<div id="view-content">
    <div class="row-fluid">
        <?php if ($this->isAdmin) { ?>
            <a class="btn btn-success" href="<?= $this->url(array(), 'project-add'); ?>"><i class="icon-white icon-plus-sign"></i> Add New Project</a>
        <?php }
        ?>
        <table class="table well">
            <thead>
                <tr>
                    <th class="span1">#</th>
                    <th class="span3">Name</th>                 
                    <th class="span2">Status</th>
                    <?php
                    if ($this->isAdmin) {
                        echo "<th class='span1'>Client</th>";
                    }
                    ?>                    
                    <th class="span3">Add More</th>
                    <th class="span1">Operation</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $index = 1;
                foreach ($this->fetchAll as $project) {
                    ?>
                    <tr class="<?= $project['class'] ?>">
                        <td><b><?= $index ?></b></td>
                        <td><?= $project['name'] ?></td>                        
                        <td><?= $project['status'] ?></td>
                        <?php
                        #get total bugs
                        $detailsDb = new Application_Model_Details();
                        $bugCounts = sizeof($detailsDb->fetchAll($project['id'], 2));
                        $featureCounts = sizeof($detailsDb->fetchAll($project['id'], 0));
                        $modificationCounts = sizeof($detailsDb->fetchAll($project['id'], 1));
                        

                        if ($this->isAdmin) {
                            echo "<td>" . $project['user']['name'] . "</td>";
                        }
                        ?>
                        <td>
                            <a class="btn btn-small" href="<?= $this->url(array('id' => $project['id']), 'feature'); ?>"><i class="icon-tag"></i> Features (<?=$featureCounts?>)</a>
                            <?php if ($project['finalized']) { ?>
                                <a class="btn btn-small" href="<?= $this->url(array('id' => $project['id']), 'bug'); ?>"><i class="icon-warning-sign"></i> Bugs (<?=$bugCounts?>)</a>
                                <a class="btn btn-small" href="<?= $this->url(array('id' => $project['id']), 'modification'); ?>"><i class="icon-screenshot"></i> Modifications (<?=$modificationCounts?>)</a>
                            <?php }
                            ?>                          
                        </td>                    
                        <td>
                            <a class="btn btn-small" href="<?= $this->url(array('id' => $project['id']), 'project-info'); ?>"><i class="icon-info-sign"></i></a>
                            <?php if ($this->isAdmin) { ?>
                                <a class="btn btn-small" href="<?= $this->url(array('id' => $project['id']), 'project-edit'); ?>"><i class="icon-edit"></i></a>
                                <?php }
                                ?>
                        </td>
                    </tr>
                    <?php
                    $index++;
                }
                ?>
            </tbody>
        </table>
    </div>
</div>